package net.tv90.bfmccore.util.area;

import lombok.Data;
import net.tv90.bfmccore.util.vector.Vector3i;

@Data
public class RectangleArea3i implements Area{

    //矩形区域的两个顶点
    private Vector3i vertex1;
    private Vector3i vertex2;

    public RectangleArea3i(Vector3i vector3i, Vector3i vector3i1) {
        this.vertex1 = vector3i;
        this.vertex2 = vector3i1;
    }

    @Override
    public boolean isInArea(Vector3i point3i) {
        if(point3i == null) return false;
        int x = point3i.getX();
        int y = point3i.getY();
        int z = point3i.getZ();
        int x1 = vertex1.getX();
        int y1 = vertex1.getY();
        int z1 = vertex1.getZ();
        int x2 = vertex2.getX();
        int y2 = vertex2.getY();
        int z2 = vertex2.getZ();
        return x >= Math.min(x1, x2) && x <= Math.max(x1, x2)
                && y >= Math.min(y1, y2) && y <= Math.max(y1, y2)
                && z >= Math.min(z1, z2) && z <= Math.max(z1, z2);
    }
}
